package io;

import java.io.Serializable;
import java.util.Arrays;

/**
 * 使用当前类测试对象流的序列化与反序列化操作
 */
public class Person implements Serializable {

    public static final long serialVersionUID = 1L;

    //姓名
    private String name;
    //性别
    private String gender;
    //年龄
    private int age;
    //其他信息
    /*
        transient关键字，当一个对象进行序列化时会忽略被该关键字修饰的属性，达到对象
        "瘦身"的目的。忽略不必要的属性可以减少资源的开销。
     */
    private transient String[] otherInfo;


    public Person(String name, String gender, int age, String[] otherInfo) {
        this.name = name;
        this.gender = gender;
        this.age = age;
        this.otherInfo = otherInfo;
    }

    public String getName() {
        return name;
    }

    public void setName(String name) {
        this.name = name;
    }

    public String getGender() {
        return gender;
    }

    public void setGender(String gender) {
        this.gender = gender;
    }

    public int getAge() {
        return age;
    }

    public void setAge(int age) {
        this.age = age;
    }

    public String[] getOtherInfo() {
        return otherInfo;
    }

    public void setOtherInfo(String[] otherInfo) {
        this.otherInfo = otherInfo;
    }

    @Override
    public String toString() {
        return "Person{" +
                "name='" + name + '\'' +
                ", gender='" + gender + '\'' +
                ", age=" + age +
                ", otherInfo=" + Arrays.toString(otherInfo) +
                '}';
    }
}
